#include "uart.h"

void uart0_init(void)
{
	P0M1 &= ~0x80; // P07
	P0M2 &= ~0x80;
	P0M1 &= ~0x40; // P06
	P0M2 &= ~0x40;
	
	SCON = 0x50;
	PCON |= 0x80;
	T3CON &= 0xF8;
	T3CON |= 0x20;
	
	RH3 = (65536 - (1000000/115200)-1) / 256;  		/*16 MHz */
	RL3 = (65536 - (1000000/115200)-1) % 256;			/*16 MHz */
	
	T3CON |= 0x08;
	TI = 1;						//For printf function must setting TI = 1
}

void uart0_sendData(unsigned char c)
{
	TI = 0;
	SBUF = c;
	while(TI==0);
}
